package com.kotlin.use.api

import androidx.room.Room
import com.kotlin.use.base.MyApplication
import com.kotlin.use.bean.User
import com.kotlin.use.repository.RoomDatabase

class APIDatabase {
    private val userDao: RoomUsers = Room.databaseBuilder(
        MyApplication.getContext(), RoomDatabase::class.java, "database001"
    ).build().roomUsers()

    fun query(): List<User> {
        return userDao.getUsers()
    }

    fun insert(user: User) {
        userDao.insertUser(user)

    }

    fun delete(name:String) {
        userDao.deleteUser(name)
    }

    fun update(name: String, age: Int) {
        userDao.updateUser(name, age)
    }


}